Skip to content

fix: add types condition to package.json exports field#1081

Merged
robertsLando merged 1 commit intomainfrom
fix/exports-types-condition
Mar 9, 2026
Merged

fix: add types condition to package.json exports field#1081
robertsLando merged 1 commit intomainfrom
fix/exports-types-condition

Conversation

@robertsLando
Copy link
Copy Markdown
Member

Summary

  • Adds a types condition to the exports field in package.json so TypeScript can resolve type declarations when using moduleResolution: "node16", "nodenext", or "bundler"
  • Without this, users get TS2305: Module '"aedes"' has no exported member 'Aedes' because TypeScript ignores the top-level "types" field when the exports field is present

Closes #1080

Test plan

  • npm run test:typescript (tsd) passes
  • npm run lint passes

🤖 Generated with Claude Code

When using TypeScript with moduleResolution set to "node16", "nodenext",
or "bundler", the compiler resolves types through the exports field and
ignores the top-level "types" entry. This caused TS2305 errors like:
Module '"aedes"' has no exported member 'Aedes'.

Adding the "types" condition inside the exports map fixes resolution for
all moduleResolution strategies.

Closes #1080

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 9, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.47%. Comparing base (322e6a7) to head (0eae649).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1081   +/-   ##
=======================================
  Coverage   99.47%   99.47%           
=======================================
  Files          15       15           
  Lines        1921     1921           
=======================================
  Hits         1911     1911           
  Misses         10       10           
Flag Coverage Δ
unittests 99.47% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@robertsLando robertsLando merged commit d78fec9 into main Mar 9, 2026
27 checks passed
robertsLando added a commit that referenced this pull request Mar 27, 2026
## Summary
- Adds `.js` extensions to all relative imports in `.d.ts` type
definition files
- Fixes TypeScript `moduleResolution: "node16"` failing to resolve types
when importing `aedes`

Closes #1082

## Details

With `moduleResolution: "node16"` and `"type": "module"`, TypeScript
strictly requires file extensions on relative imports. PR #1081 added
the `types` condition to `package.json` exports, allowing TypeScript to
find the entry `aedes.d.ts`, but the internal relative imports within
the `.d.ts` files still lacked `.js` extensions, causing resolution
failures.

**Files changed:**
- `aedes.d.ts` — entry point re-exports
- `types/client.d.ts` — imports from `packet` and `instance`
- `types/instance.d.ts` — imports from `client` and `packet`
- `types/packet.d.ts` — imports from `client`
- `test/types/aedes.test-d.ts` — test import from `types/packet`

## Test plan
- [x] `npm run test:typescript` (tsd) passes

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[question] Module '"aedes"' has no exported member 'Aedes'

1 participant